package juc.executors;

import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

public class ExecutorServiceExample5 {

    public static void main(String[] args) {
        ThreadPoolExecutor executorService = (ThreadPoolExecutor)Executors.newFixedThreadPool(5);
        //不会被执行，因为通过submit、execute、invoke接收任务时，有个信号触发线程池里的线程的创建执行
        //executorService.getQueue().add(()-> System.out.println("I am added directly into the queue"));

        executorService.execute(()-> System.out.println("i will be process because of triggered the execute."));
        //会执行，因为线程池里有一个active的线程执行完成后会到队列里取
        executorService.getQueue().add(()-> System.out.println("I am added directly into the queue"));

    }
}
